<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<style>
    .queueList {
        height: 270px;
    }

    .form-group {
        width: 700px;
        text-align: center;
    }
</style>
<link th:href="@{/css/plugins/webuploader/webuploader.css}" rel="stylesheet"/>
<link th:href="@{/css/demo/webuploader-demo.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/iCheck/custom.css}" rel="stylesheet"/>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-products-edit" th:object="${products}">
        <input id="id" name="id" th:field="*{id}" type="hidden">
        <div class="col-md-6">
            <div class="form-group">
                <div id="image_links">
                    <a th:href='@{/profile/product/}+*{picUrl}' title="Banana">
                        <img width="60px" height="60px;" th:src='@{/profile/product/}+*{picUrl}' alt="Banana">
                    </a>
                </div>
            </div>
        </div>

        <div class="col-md-6">
            <div class="form-group">
                <label class="col-sm-3 control-label"><span class="must_be_color">*</span>mainSKU：</label>
                <div class="col-sm-9">
                    <input type="text" name="mainSKU" class="form-control" th:field="*{mainSKU}" disabled
                           placeholder="Please enter text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label"><span class="must_be_color">*</span>productName：</label>
                <div class="col-sm-9">
                    <input type="text" name="productName" th:field="*{productName}" class="form-control" disabled
                           placeholder="Please enter text">
                </div>
            </div>

        </div>
        <div class="col-md-6">
            <div class="form-group">
                <label class="col-sm-3 control-label">purchase：</label>
                <div class="col-sm-9">
                    <input type="text" id="purchaseQuantity" name="purchaseQuantity" th:field="*{purchaseQuantity}"
                           class="form-control" placeholder="Please enter text">
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="form-group">
                <label class="col-sm-3 control-label">confirm：</label>
                <div class="col-sm-9">
                    <input type="text" id="submitQuantity" name="submitQuantity" th:field="*{submitQuantity}"
                           class="form-control" placeholder="Please enter text">
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="form-group">
                <label class="col-sm-3 control-label">work off：</label>
                <div class="col-sm-9">
                    <input type="text" id="soldQuantity" name="soldQuantity" th:field="*{soldQuantity}"
                           class="form-control" placeholder="Please enter text">
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="form-group">
                <label class="col-sm-3 control-label">sales return：</label>
                <div class="col-sm-9">
                    <input type="text" id="refundQuantity" name="refundQuantity" th:field="*{refundQuantity}"
                           class="form-control" placeholder="Please enter text">
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="form-group">
                <label class="col-sm-3 control-label">sales return enter warehouse：</label>
                <div class="col-sm-9">
                    <input type="text" id="refundPutInQuantity" name="refundPutInQuantity"
                           th:field="*{refundPutInQuantity}" class="form-control" placeholder="Please enter text">
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="form-group">
                <label class="col-sm-3 control-label">return goods loss：</label>
                <div class="col-sm-9">
                    <input type="text" id="refundLossQuantity" name="refundLossQuantity"
                           th:field="*{refundLossQuantity}" class="form-control" placeholder="Please enter text">
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="form-group">
                <label class="col-sm-3 control-label">Domestic warehouse loss：</label>
                <div class="col-sm-9">
                    <input type="text" id="chinaStorageLossQuantity" name="chinaStorageLossQuantity"
                           th:field="*{chinaStorageLossQuantity}" class="form-control" placeholder="Please enter text">
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="form-group">
                <label class="col-sm-3 control-label">Loss of overseas warehouse：</label>
                <div class="col-sm-9">
                    <input type="text" id="overseasStorageLossQuantity" name="overseasStorageLossQuantity"
                           th:field="*{overseasStorageLossQuantity}" class="form-control" placeholder="Please enter text">
                </div>
            </div>
        </div>
        <!--<div class="col-md-6">
            <div class="form-group">
                <label class="col-sm-3 control-label">库存：</label>
                <div class="col-sm-9">
                    <input type="text" id="kc" name="" class="form-control" placeholder="Please enter text">
                </div>
            </div>
        </div>-->
        <div class="form-group">
            <div class="form-control-static col-sm-offset-9">
                <button type="submit" class="btn btn-primary">submit</button>
                <button onclick="$.modal.close()" class="btn btn-danger" type="button">close</button>
            </div>
        </div>
    </form>
</div>
<div th:include="include::footer"></div>
<div th:include="include::footer"></div>
<script th:src="@{/ajax/libs/select/select2.js}"></script>
<script type="text/javascript">

    initialize_image();

    $("#form-products-edit").validate({
        rules: {
            mainSKU: {
                required: true,
            },
            productName: {
                required: true,
            }
        },
        submitHandler: function (form) {
            edit();
        }
    });

    function edit () {
        var id = $("input[name='id']").val();
        var purchaseQuantity = $("input[name='purchaseQuantity']").val();
        var submitQuantity = $("input[name='submitQuantity']").val();
        var soldQuantity = $("input[name='soldQuantity']").val();
        var refundQuantity = $("input[name='refundQuantity']").val();
        var refundPutInQuantity = $("input[name='refundPutInQuantity']").val();
        var refundLossQuantity = $("input[name='refundLossQuantity']").val();
        var chinaStorageLossQuantity = $("input[name='chinaStorageLossQuantity']").val();
        var overseasStorageLossQuantity = $("input[name='overseasStorageLossQuantity']").val();
        $.ajax({
            cache: true,
            type: "POST",
            url: ctx + "module/products/edit",
            data: {
                "id": id,
                "purchaseQuantity": purchaseQuantity,
                "submitQuantity": submitQuantity,
                "soldQuantity":soldQuantity,
                "refundQuantity": refundQuantity,
                "refundPutInQuantity": refundPutInQuantity,
                "refundLossQuantity": refundLossQuantity,
                "chinaStorageLossQuantity": chinaStorageLossQuantity,
                "overseasStorageLossQuantity": overseasStorageLossQuantity,
            },
            async: false,
            error: function (request) {
                $.modal.alertError("system error");
            },
            success: function (data) {
                $.operate.saveSuccess(data);
            }
        });
    }

</script>

</body>
</html>
